package com.luzh.myspring.context.event;

import com.luzh.myspring.beans.factory.BeanFactory;
import com.luzh.myspring.context.ApplicationEvent;
import com.luzh.myspring.context.ApplicationListener;

/**
 * 简单广播器
 */
public class SimpleApplicationEventMulticaster extends AbstractApplicationEventMulticaster {

    public SimpleApplicationEventMulticaster(BeanFactory beanFactory) {
        setBeanFactory(beanFactory);
    }

    /**
     * 向感兴趣的监听器广播事件
     * @param event
     */
    @Override
    public void multicastEvent(final ApplicationEvent event) {
        for (final ApplicationListener<ApplicationEvent> listener : getApplicationListeners(event)) {
            listener.onApplicationEvent(event);
        }
    }

}
